$(".btn-primary").on('click',function(){
	// alert('dute');
	if($('#validation-form').valid()){		
		dataSend = $("#validation-form").serialize();
		$(".control-group:last .notvalid").remove();
		
		$.ajax({
			type: "POST",			
			data: dataSend,
			url: "http://mobilaro.localhost/admin/libs/login_ajax.php",			
			success: function(data){ 
				
				if(data!=null){
					window.location.replace("http://mobilaro.localhost/admin/blank.php?page=profile");
				}else{
					$(".control-group:last").append('<span class="notvalid pink">Password or username incorect!</span>')
					
				}
			}
		});

	} 
});



$(function(){
			
				$('[data-rel=tooltip]').tooltip();
			
				
			
				var $validation = false;			
			
				//documentation : http://docs.jquery.com/Plugins/Validation/validate
			
			
				
			
				$('#validation-form').validate({
					errorElement: 'span',
					errorClass: 'help-inline pink',
					focusInvalid: false,
					rules: {
						email: {
							required: true,
							email:true
						},
						password: {
							required: true,
							minlength: 5
						},
			
					messages: {
						email: {
							required: "Please provide a valid email.",
							email: "Please provide a valid email."
						},
						password: {
							required: "Please specify a password.",
							minlength: "Please specify a secure password."
						},
						subscription: "Please choose at least one option",
						gender: "Please choose gender",
						agree: "Please accept our policy"
					},
			
					invalidHandler: function (event, validator) { //display error alert on form submit   
						$('.alert-error', $('.login-form')).show();
					},
			
					highlight: function (e) {
						$(e).closest('.control-group').removeClass('info').addClass('error');
					},
			
					success: function (e) {
						$(e).closest('.control-group').removeClass('error').addClass('info');
						$(e).remove();
					},
			
					errorPlacement: function (error, element) {
						if(element.is(':checkbox') || element.is(':radio')) {
							var controls = element.closest('.controls');
							if(controls.find(':checkbox,:radio').length > 1) controls.append(error);
							else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
						}
						else if(element.is('.select2')) {
							error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
						}
						else if(element.is('.chzn-select')) {
							error.insertAfter(element.siblings('[class*="chzn-container"]:eq(0)'));
						}
						else error.insertAfter(element);
					},
			
					submitHandler: function (form) {
					},
					invalidHandler: function (form) {
					}
				}
				});
			
				
				
				
				
			});
